<!DOCTYPE >
<html xmlns:th="http://www.thymeleaf.org" lang="ch">
<head>
    <base th:href="@{/}">
    <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1" />
    <link rel="stylesheet" type="text/css" href="../static/login.css">
    <title>惠院选课系统</title>
</head>
<body>
<div id="title">
   惠院选课
</div>
<div id="content">
    <h1 >Welcome</h1><br />
<!--    <form action="/student/mlogin" method="post" >-->
        身份：<input type="text" name="identity" id="identity" list="typelist" placeholder="请选择身份"/>
        <datalist id="typelist">
            <option>学生</option>
            <option>教师</option>
        </datalist><br /><br />
        帐号：<input type="text" name="userid" id="userid" placeholder="请输入账号" /><br /><br />
        密码：<input type="password" name="password" id="password" placeholder="请输入密码" /><br /><br />
        <input type="button" name="login" id="btn" value="立即登录" onclick="btn()"/>
<!--        <input type="submit" name="login" id="btn" value="立即登录"/>-->
<!--</form>-->

</div>
</body>
<script>
    function btn() {
        var identity = document.getElementById("identity").value;
        var userid = document.getElementById("userid").value;
        var password = document.getElementById("password").value;
        $.ajax({
            url:"/student/mlogin",
            type: "GET",
            data:{
                identity: identity,
                userid: userid,
                password: password,
            },
            success: function (success) {
                if(success=="null"){
                    alert("该用户不存在！！！");
                    //window.open("/student/login","_self");
                }else if(success=="error"){
                    alert("密码错误！！！");
                }else{
                    window.open(success,"_self");
                }
            },
            error:function (error) {
                alert("请检查网络连接！");
            }
        })
    }
</script>
<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script>window.jp || document.write('<script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.24/assets/js/vendor/jquery.min.js"><\/script>')</script>
</html>
